home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / eagui30.lha / EAGUI / Modula2 / txt / Pages.mod < prev    next >
Encoding:
Text File  |  1994-12-01  |  15.7 KB  |  673 lines

  1. (* REVISION HEADER ×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× *
  2.    
  3.  | $VER: Pages 3.00 (23.11.94) by Stefan Schulz [sts]
  4.  
  5.  | Desc: Advanced Example for using EAGUI via M2
  6.  
  7.  | Dist: This Module is © Copyright 1994 by Stefan Schulz
  8.  
  9.  | Rqrs: Amiga OS 2.0 or higher
  10.  |       EAGUI.library V3
  11.  |       EAGUI - Environment Adaptive Graphic User Interface
  12.  |       Copyright © 1993, 1994 by Marcel Offermans and Frank Groen
  13.  
  14.  | Lang: M2Amiga
  15.  | Trns: M2Amiga Modula 2 Software Development System
  16.  |       © Copyright by A+L AG, CH-2540 Grenchen
  17.  
  18.  | Hist: Version \date\
  19.  |
  20.  |       3.00   \23.11.94\
  21.  |              initial Version
  22.  
  23.  * ×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× *)
  24.  
  25. MODULE Pages;
  26.  
  27. (*$ DEFINE    Small:= FALSE
  28.  
  29.     IF    Small
  30.     StackChk   := FALSE
  31.     RangeChk   := FALSE
  32.     OverflowChk:= FALSE
  33.     NilChk     := FALSE
  34.     EntryClear := FALSE
  35.     CaseChk    := FALSE
  36.     ReturnChk  := FALSE
  37.     LargeVars  := FALSE
  38.     ENDIF            *)
  39.  
  40. (* IMPORTS ********************************************************************** *)
  41.  
  42. IMPORT    tf    : TextField;
  43.  
  44. IMPORT    d    : EAGuiD,
  45.     l    : EAGuiL,
  46.     m    : EAGuiMacros;
  47.  
  48. IMPORT    A    : Arts,
  49.     ar    : Arguments,
  50.     cv    : Conversions,
  51.     dfl    : DiskFontL,
  52.     dl    : DosL,
  53.     ed    : ExecD,
  54.     el    : ExecL,
  55.     gtd    : GadToolsD,
  56.     gtl    : GadToolsL,
  57.     gd    : GraphicsD,
  58.     gl    : GraphicsL,
  59.     hp    : Heap,
  60.     id    : IntuitionD,
  61.     il    : IntuitionL,
  62.     R,
  63.     S    : SYSTEM,
  64.     ud    : UtilityD;
  65.  
  66. (* ****************************************************************************** *)
  67.  
  68. (* GLOBALS ====================================================================== *)
  69.  
  70. CONST    WindowTitle    = "EAGUI pages Example";
  71.     ErrNoDrawInfo    = "Couldn't get the draw info.\n";
  72.     ErrNoFont    = "Couldn't open font.\n";
  73.     ErrNoGadList    = "Couldn't create the gadget list.\n";
  74.     ErrNoObjects    = "Couldn't init the objects.\n";
  75.     ErrNoScreenLock    = "Couldn't lock default public screen.\n";
  76.     ErrNoVisualInfo    = "Couldn't get the visual info.\n";
  77.     ErrNoWindow    = "Couldn't open the window.\n";
  78.  
  79. CONST    DefaultFont    = "helvetica.font";
  80.  
  81. CONST    LayoutSpacing    = 4;
  82.     CycleGadgetID    = 666;
  83.  
  84. VAR    WinObj,
  85.     PGroupObj,
  86.     Page1,
  87.     Page2,
  88.     Page3        : d.OPTR;
  89.     
  90.     Win        : id.WindowPtr;
  91.     Scr        : id.ScreenPtr;
  92.     GadList        : id.GadgetPtr;
  93.     CycleGadget    : id.GadgetPtr;
  94.     
  95.     VisualInfo    : S.ADDRESS;
  96.     DrawInfo    : id.DrawInfoPtr;
  97.     TextFont    : gd.TextFontPtr;
  98.     
  99.     TextAttr    := gd.TextAttr {name  : S.ADR(DefaultFont),
  100.                     ySize : 15,
  101.                     style : gd.normalFont,
  102.                     flags : gd.FontFlagSet{gd.diskFont}
  103.                        };
  104.     PgMinSizeHook,
  105.     TFMinSizeHook,
  106.     TFRenderHook    : ud.Hook;
  107.     IMsg        : id.IntuiMessage;
  108.     TextField    : tf.ciTextField;
  109.  
  110. TYPE    LabelArray    = ARRAY [0..3] OF d.StrPtr;
  111.     CyTagList    = ARRAY [0..2] OF ud.TagItem;
  112.  
  113. VAR    Labels        := LabelArray
  114.     { S.ADR("Page One"),
  115.       S.ADR("Page Two"),
  116.       S.ADR("Page Three"),
  117.       NIL
  118.     };
  119.  
  120.     cyTagList    : CyTagList;
  121.  
  122. (* ============================================================================== *)
  123.  
  124. (* page group minsize method ---------------------------------------------------- *)
  125. PROCEDURE MethMinSizePGroup(    hook{R.A0}  : ud.HookPtr;
  126.                 obj{R.A2}   : S.ADDRESS;
  127.                 msg{R.A1}   : S.ADDRESS        ) : S.ADDRESS;
  128.  
  129.  TYPE    MsgTagListPtr    = POINTER TO MsgTagList;
  130.     MsgTagList    = ARRAY [1..16] OF LONGINT;
  131.  
  132.  VAR    current        : d.OPTR;
  133.     minwidth,
  134.     minheight,
  135.     width, height,
  136.     mwidth, mheight,
  137.     bleft, bright,
  138.     btop, bbottom    : LONGCARD;
  139.     msgTagListBuf    : MsgTagList;
  140.     msgTagList    : MsgTagListPtr;
  141.  
  142.  (*$ SaveA4:= TRUE *)
  143.  
  144.  BEGIN
  145.  
  146.  S.SETREG( R.A4, hook^.data );
  147.  
  148.  (* starting values *)
  149.  minwidth  := 0;
  150.  minheight := 0;
  151.  current   := l.GetAttr(obj, d.firstChild);
  152.  
  153.  msgTagList:= S.TAG(msgTagListBuf,
  154.             d.minWidth,        0,
  155.             d.minHeight,    0,
  156.             d.borderLeft,    0,
  157.             d.borderRight,    0,
  158.             d.borderTop,    0,
  159.             d.borderBottom,    0,
  160.             d.nextObject,    0,
  161.           ud.tagDone);
  162.  
  163.  msgTagListBuf[2] := S.ADR(mwidth);
  164.  msgTagListBuf[4] := S.ADR(mheight);
  165.  msgTagListBuf[6] := S.ADR(bleft);
  166.  msgTagListBuf[8] := S.ADR(bright);
  167.  msgTagListBuf[10]:= S.ADR(btop);
  168.  msgTagListBuf[12]:= S.ADR(bbottom);
  169.  msgTagListBuf[14]:= S.ADR(current);
  170.  
  171.  (* do all children *)
  172.  WHILE (current # NIL)
  173.   DO    (* get the required attributes *)
  174.     IGNORE l.GetAttrsA(current, S.ADDRESS(msgTagList));
  175.     
  176.     (* determine the minimum dimensions of this child *)
  177.     width := mwidth + bleft + bright;
  178.     height:= mheight + btop + bbottom;
  179.     
  180.     (* check and use these dimensions if they were larger than the largest    *)
  181.     (* up to now                                  *)
  182.     IF (height > minheight) THEN minheight:= height  END;
  183.     IF (width > minwidth)   THEN minwidth := width   END;
  184.     
  185.   END; (* while *)
  186.  
  187.  (* set the minimum dimensions of the object *)
  188.  IGNORE l.SetAttr(obj, d.minWidth,  minwidth);
  189.  IGNORE l.SetAttr(obj, d.minHeight, minheight);
  190.  
  191.  (* return zero for success *)
  192.  RETURN NIL;
  193.  
  194.  END MethMinSizePGroup;
  195.  
  196.  
  197.  
  198. (* Recreate the gadget-list ----------------------------------------------------- *)
  199.  
  200. PROCEDURE ResizeWindow;
  201.  
  202.  VAR    bLeft, bRight,
  203.     bTop, bBottom    : LONGINT;
  204.     int        : INTEGER;
  205.     buffer        : ARRAY [1..10] OF LONGINT;
  206.  
  207.  BEGIN
  208.  
  209.  (* if necessary, remove the gadget list from the window, and clean it up      *)
  210.  IF    (GadList # NIL)
  211.   THEN    int:= il.RemoveGList(Win, GadList, -1);
  212.     l.FreeGadgetList(WinObj, GadList);
  213.     GadList:= NIL;
  214.   END; (* if *)
  215.  
  216.  IGNORE l.GetAttrsA
  217.     ( WinObj,
  218.       S.TAG(buffer,
  219.         d.borderLeft,   S.ADR(bLeft),
  220.         d.borderRight,  S.ADR(bRight),
  221.         d.borderTop,    S.ADR(bTop),
  222.         d.borderBottom, S.ADR(bBottom),
  223.       ud.tagDone)
  224.     ); (* l.GetAttrsA *)
  225.  
  226.  IGNORE l.SetAttrsA
  227.     ( WinObj,
  228.       S.TAG(buffer,
  229.         d.width, Win^.width - Win^.borderLeft - Win^.borderRight
  230.              - bLeft - bRight,
  231.         d.height, Win^.height - Win^.borderTop - Win^.borderBottom
  232.              - bTop - bBottom,
  233.         d.left,  Win^.borderLeft,
  234.         d.top,   Win^.borderTop,
  235.       ud.tagDone)
  236.     ); (* l.SetAttrsA *)
  237.  
  238.  l.LayoutObjects(WinObj);
  239.  
  240.  A.Assert(l.CreateGadgetList(WinObj, S.ADR(GadList), VisualInfo, DrawInfo)
  241.       = d.errorOK,
  242.       S.ADR(ErrNoGadList)
  243.      );
  244.  
  245.  gl.EraseRect(Win^.rPort, Win^.borderLeft, Win^.borderTop,
  246.           Win^.width - Win^.borderRight - 1,
  247.           Win^.height - Win^.borderBottom - 1
  248.          );
  249.  
  250.  il.RefreshWindowFrame(Win);
  251.  
  252.  int:= il.AddGList(Win, GadList, -1, -1, NIL);
  253.  il.RefreshGList(GadList, Win, NIL, -1);
  254.  gtl.GTRefreshWindow(Win, NIL);
  255.  
  256.  (* finally, we render the imagery, if there is any              *)
  257.  l.RenderObjects(WinObj, Win^.rPort);
  258.  
  259.  END ResizeWindow;
  260.  
  261.  
  262.  
  263. (* (re)create the gadget list after a page change ------------------------------- *)
  264. PROCEDURE RePageWindow;
  265.  
  266.  VAR    bLeft, bRight,
  267.     bTop, bBottom,
  268.     gwidth, gheight,
  269.     gtop, gleft    : LONGINT;
  270.     buffer        : ARRAY [1..10] OF LONGINT;
  271.  
  272.  BEGIN
  273.  
  274.  (* if necessary, remove the gadget list from the window, and clean it up *)
  275.  (* if necessary, remove the gadget list from the window, and clean it up      *)
  276.  IF    (GadList # NIL)
  277.   THEN    IGNORE il.RemoveGList(Win, GadList, -1);
  278.     l.FreeGadgetList(WinObj, GadList);
  279.     GadList:= NIL;
  280.   END; (* if *)
  281.  
  282.  IGNORE l.GetAttrsA
  283.     ( WinObj,
  284.       S.TAG(buffer,
  285.         d.borderLeft,   S.ADR(bLeft),
  286.         d.borderRight,  S.ADR(bRight),
  287.         d.borderTop,    S.ADR(bTop),
  288.         d.borderBottom, S.ADR(bBottom),
  289.       ud.tagDone)
  290.     ); (* l.GetAttrsA *)
  291.  
  292.  IGNORE l.SetAttrsA
  293.     ( WinObj,
  294.       S.TAG(buffer,
  295.         d.width, Win^.width - Win^.borderLeft - Win^.borderRight
  296.              - bLeft - bRight,
  297.         d.height, Win^.height - Win^.borderTop - Win^.borderBottom
  298.              - bTop - bBottom,
  299.         d.left,  Win^.borderLeft,
  300.         d.top,   Win^.borderTop,
  301.       ud.tagDone)
  302.     ); (* l.SetAttrsA *)
  303.  
  304.  l.LayoutObjects(WinObj);
  305.  
  306.  A.Assert(l.CreateGadgetList(WinObj, S.ADR(GadList), VisualInfo, DrawInfo)
  307.       = d.errorOK,
  308.       S.ADR(ErrNoGadList)
  309.      );
  310.  
  311.  (* now determine the exact position of the page in the window *)
  312.  gleft  := l.GetObjectLeft(WinObj, PGroupObj);
  313.  gtop   := l.GetObjectTop(WinObj, PGroupObj);
  314.  gwidth := l.GetAttr(PGroupObj, d.width);
  315.  gheight:= l.GetAttr(PGroupObj, d.height);
  316.  
  317.  (* clear only the page instead of the complete window *)
  318.  gl.EraseRect(Win^.rPort, gleft, gtop, gleft+gwidth-1, gtop+gheight-1);
  319.  
  320.  IGNORE il.AddGList(Win, GadList, -1, -1, NIL);
  321.  il.RefreshGList(GadList, Win, NIL, -1);
  322.  gtl.GTRefreshWindow(Win, NIL);
  323.  
  324.  (* finally, we render the imagery, if there is any *)
  325.  l.RenderObjects(WinObj, Win^.rPort);
  326.  
  327.  END RePageWindow;
  328.  
  329.  
  330.  
  331. (* Init all --------------------------------------------------------------------- *)
  332.  
  333. PROCEDURE Init;
  334.  
  335.  VAR    width, height,
  336.     bLeft, bRight,
  337.     bTop, bBottom    : LONGINT;
  338.     buffer1,
  339.     buffer2        : ARRAY [1..50] OF LONGINT;
  340.     buffer3        : ARRAY [1..8] OF LONGINT;
  341.     bool        : BOOLEAN;
  342.  
  343.  BEGIN
  344.  
  345.  (* Initialize CycleTagList *) 
  346.  IGNORE  S.TAG( cyTagList,
  347.         gtd.gtcyLabels, S.ADR(Labels),
  348.         gtd.gtcyActive, 0,
  349.      ud.tagDone);
  350.  
  351.  (* open the font *)
  352.  TextFont:= dfl.OpenDiskFont(S.ADR(TextAttr));
  353.  A.Assert(TextFont # NIL, S.ADR(ErrNoFont));
  354.  
  355.  (* initialize the pagegroup minsize hook *)
  356.  PgMinSizeHook.entry:= MethMinSizePGroup;
  357.  PgMinSizeHook.data := S.REG(R.A4);
  358.  
  359.  (* initialize textfield hooks *)
  360.  TFMinSizeHook.entry:= tf.MethMinSizeTextField;
  361.  TFMinSizeHook.data := S.REG(R.A4);
  362.  
  363.  TFRenderHook.entry:= tf.MethRenderTextField;
  364.  TFRenderHook.data := S.REG(R.A4);
  365.  
  366.  (* set up some defaults for all objects *)
  367.  IGNORE l.SetAttr(NIL, d.defGTTextAttr, S.ADR(TextAttr));
  368.  
  369.  (* now we can build the object tree *)
  370.  
  371.  Page1:= m.GTListView( "", S.TAG(buffer1, d.weight, 1, ud.tagEnd) );
  372.  
  373.  Page2:= m.VGroup
  374.     ( S.TAG(buffer1,
  375.         d.weight,    1,
  376.         d.child,    m.EmptyBox(2, NIL),
  377.         d.child,    m.GTString("Username:",NIL),
  378.         d.child,    m.EmptyBox(1, NIL),
  379.         d.child,    m.GTString("Password:", NIL),
  380.         d.child,    m.EmptyBox(2, NIL),
  381.       ud.tagEnd)
  382.     ); (* VGroup *)
  383.  
  384.  Page3:= l.NewObjectA
  385.     ( d.typeCustomImage,
  386.       S.TAG(buffer1,
  387.         d.weight,    1,
  388.         d.borderBottom,    4,
  389.         d.minSizeMethod,S.ADR(TFMinSizeHook),
  390.         d.renderMethod,    S.ADR(TFRenderHook),
  391.         d.userData,    S.ADR(TextField),
  392.       ud.tagEnd)
  393.     ); (* NewObjectA *)
  394.  
  395.  PGroupObj:= l.NewObjectA
  396.         ( d.typeHGroup,
  397.           S.TAG(buffer1,
  398.             d.standardMethod,    d.smBorder,
  399.             d.weight,        1,
  400.             d.minSizeMethod,    S.ADR(PgMinSizeHook),
  401.             d.child, Page1,
  402.             d.child, Page2,
  403.             d.child, Page3,
  404.           ud.tagEnd)
  405.         ); (* NewObjectA *)
  406.  
  407.  WinObj:= m.HGroup
  408.         ( S.TAG(buffer1,
  409.             d.borderLeft,   LayoutSpacing,
  410.             d.borderRight,  LayoutSpacing,
  411.             d.borderTop,    LayoutSpacing,
  412.             d.borderBottom, LayoutSpacing,
  413.             d.child, m.VGroup
  414.              (S.TAG(buffer2,
  415.                 d.weight,    1,
  416.                 d.borderRight,    LayoutSpacing,
  417.                 d.child,    m.EmptyBox(1, NIL),
  418.                 d.child,    m.GTButton("Help...", NIL),
  419.                 d.child,    m.EmptyBox(1, NIL),
  420.                 d.child,    m.GTButton("Ok", NIL),
  421.                 d.child,    m.GTButton("Cancel", NIL),
  422.               ud.tagEnd)),
  423.             d.child, m.VGroup
  424.              (S.TAG(buffer2,
  425.                 d.weight,    2,
  426.                 d.child, m.GTCycle
  427.                  (S.TAG(buffer3,
  428.                     d.gtTagList,       S.ADR(cyTagList),
  429.                     d.instanceAddress, S.ADR(CycleGadget),
  430.                     d.id,           CycleGadgetID,
  431.                   ud.tagEnd)),
  432.                 d.child, PGroupObj,
  433.               ud.tagEnd)),
  434.           ud.tagEnd)
  435.         ); (* HGroup *)
  436.  
  437.  A.Assert(WinObj # NIL, S.ADR(ErrNoObjects));
  438.  
  439.  (* lock the screen *)
  440.  Scr:= il.LockPubScreen(NIL);
  441.  A.Assert(Scr # NIL, S.ADR(ErrNoScreenLock));
  442.  
  443.  (* get VisualInfo and DrawInfo *)
  444.  VisualInfo:= gtl.GetVisualInfoA(Scr, NIL);
  445.  A.Assert(VisualInfo # NIL, S.ADR(ErrNoVisualInfo));
  446.  DrawInfo:= il.GetScreenDrawInfo(Scr);
  447.  A.Assert(DrawInfo # NIL, S.ADR(ErrNoDrawInfo));
  448.  
  449.  (* fill in the textfield structure *)
  450.  TextField.string  := S.ADR("Connection Established");    (* title *)
  451.  TextField.textAttr:= S.ADR(TextAttr);            (* font  *)
  452.  TextField.flags   := tf.CITFFlagSet{};            (* alignment flags *)
  453.  TextField.frontPen:= 2;                (* frontpen color index *)
  454.  
  455.  (* obtain the minimum dimensions of every object in the tree *)
  456.  l.GetMinSizes(WinObj);
  457.  
  458.  (* get some attributes *)
  459.  IGNORE l.GetAttrsA
  460.     ( WinObj,
  461.       S.TAG(buffer1,
  462.         d.minWidth,    S.ADR(width),
  463.         d.minHeight,    S.ADR(height),
  464.         d.borderLeft,    S.ADR(bLeft),
  465.         d.borderRight,    S.ADR(bRight),
  466.         d.borderTop,    S.ADR(bTop),
  467.         d.borderBottom,    S.ADR(bBottom),
  468.       ud.tagEnd)
  469.     );
  470.  
  471.  IGNORE l.SetAttr(Page1, d.disabled, 0);
  472.  IGNORE l.SetAttr(Page2, d.disabled, 1);
  473.  IGNORE l.SetAttr(Page3, d.disabled, 1);
  474.  
  475.  (* open the window *)
  476.  Win:= il.OpenWindowTagList
  477.         ( NIL,
  478.           S.TAG(buffer1,
  479.             id.waTitle,       S.ADR(WindowTitle),
  480.             id.waFlags,       id.WindowFlagSet{id.windowDrag,
  481.                                id.windowDepth,
  482.                                id.windowClose,
  483.                                id.windowSizing,
  484.                                id.sizeBBottom,
  485.                                id.windowActive},
  486.             id.waIDCMP,       id.IDCMPFlagSet{ id.closeWindow,
  487.                                id.gadgetUp,
  488.                                id.refreshWindow,
  489.                                id.newSize},
  490.             id.waInnerHeight, height + bTop + bBottom,
  491.           ud.tagEnd)
  492.         );
  493.  
  494.  (* set the window limits *)
  495.  bool:= il.WindowLimits
  496.         ( Win,
  497.           width + Win^.borderLeft + Win^.borderRight + bLeft + bRight,
  498.           height + Win^.borderTop + Win^.borderBottom + bTop + bBottom,
  499.           0, 0
  500.         );
  501.  
  502.  (* create the gadgets and add them to the window *)
  503.  ResizeWindow;
  504.  
  505.  END Init;
  506.  
  507.  
  508.  
  509. (* Clean up --------------------------------------------------------------------- *)
  510. PROCEDURE CleanUp;
  511.  
  512.  VAR    int    : INTEGER;
  513.  
  514.  BEGIN
  515.  
  516.  IF    (GadList # NIL)
  517.   THEN    int:= il.RemoveGList(Win, GadList, -1);
  518.     l.FreeGadgetList(WinObj, GadList);
  519.     GadList:= NIL;
  520.   END; (* if *)
  521.  
  522.  IF    (Win # NIL)
  523.   THEN    il.CloseWindow(Win);
  524.     Win:= NIL;
  525.   END;
  526.  
  527.  IF    (DrawInfo # NIL)
  528.   THEN    il.FreeScreenDrawInfo(Scr, DrawInfo);
  529.     DrawInfo:= NIL;
  530.   END;
  531.  
  532.  IF    (VisualInfo # NIL)
  533.   THEN    gtl.FreeVisualInfo(VisualInfo);
  534.     VisualInfo:= NIL;
  535.   END;
  536.  
  537.  IF    (Scr # NIL)
  538.   THEN    il.UnlockPubScreen(NIL, Scr);
  539.     Scr:= NIL;
  540.   END;
  541.  
  542.  IF    (WinObj # NIL)
  543.   THEN    l.DisposeObject(WinObj);
  544.     WinObj:= NIL;
  545.   END;
  546.  
  547.  IF    (TextFont # NIL)
  548.   THEN    gl.CloseFont(TextFont);
  549.     TextFont:= NIL;
  550.   END;
  551.  
  552.  END CleanUp;
  553.  
  554.  
  555.  
  556. (* Message Handling ------------------------------------------------------------- *)
  557.  
  558. PROCEDURE HandleMsgs () : LONGCARD;
  559.  
  560.  VAR    iMsg        : id.IntuiMessagePtr;
  561.     rc        : LONGCARD;
  562.     buffer        : ARRAY [1..4] OF LONGINT;
  563.     adr        : S.ADDRESS;
  564.     test        : ARRAY [1..10] OF LONGCARD;
  565.  
  566.  BEGIN
  567.  
  568.  rc:= 0;
  569.  
  570.  REPEAT    iMsg:= gtl.GTGetIMsg(Win^.userPort);
  571.     IF    (iMsg # NIL)
  572.      THEN    el.CopyMem(iMsg, S.ADR(IMsg), SIZE(IMsg));
  573.         gtl.GTReplyIMsg(iMsg);
  574.         
  575.         IF    (id.refreshWindow IN IMsg.class)
  576.          THEN    gtl.GTBeginRefresh(Win);
  577.             gtl.GTEndRefresh(Win, TRUE);
  578.          ELSIF    (id.closeWindow IN IMsg.class)
  579.           THEN    rc:= 10;
  580.          ELSIF    (id.newSize IN IMsg.class)
  581.           THEN    ResizeWindow;
  582.          ELSIF    (id.gadgetUp IN IMsg.class)
  583.           THEN    (* check if the user clicked on the cycle gadget *)
  584.             IF (id.GadgetPtr(IMsg.iAddress)^.gadgetID = CycleGadgetID)
  585.              THEN    (* the user clicked on the cycle gadget and       *)
  586.                 (* selected a different page                      *)
  587.                 cyTagList[1].data:= IMsg.code;
  588.                 
  589.                 (* enable and disable the right pages *)
  590.                 IF    (IMsg.code = 0)
  591.                  THEN    IGNORE l.SetAttr(Page1, d.disabled, 0);
  592.                     IGNORE l.SetAttr(Page2, d.disabled, 1);
  593.                     IGNORE l.SetAttr(Page3, d.disabled, 1);
  594.                  ELSIF    (IMsg.code = 1)
  595.                   THEN    IGNORE l.SetAttr(Page1, d.disabled, 1);
  596.                     IGNORE l.SetAttr(Page2, d.disabled, 0);
  597.                     IGNORE l.SetAttr(Page3, d.disabled, 1);
  598.                  ELSE    IGNORE l.SetAttr(Page1, d.disabled, 1);
  599.                     IGNORE l.SetAttr(Page2, d.disabled, 1);
  600.                     IGNORE l.SetAttr(Page3, d.disabled, 0);
  601.                  END; (* if *)
  602.                 
  603.                 (* refresh the window and the gadgets *)
  604.                 RePageWindow;
  605.              ELSE (* ooops :*)
  606.              END; (* if *)
  607.          END; (* if *)
  608.      END; (* if *)
  609.  UNTIL (iMsg = NIL);
  610.  
  611.  RETURN rc;
  612.  
  613.  END HandleMsgs;
  614.  
  615.  
  616.  
  617. (* Get submitted arguments ------------------------------------------------------ *)
  618.  
  619. PROCEDURE GetArguments;
  620.  
  621.  VAR    strBuf        : ARRAY [0..127] OF CHAR;
  622.     argNum, len    : INTEGER;
  623.     signed, err    : BOOLEAN;
  624.     long        : LONGINT;
  625.  
  626.  BEGIN
  627.  
  628.  argNum:= ar.NumArgs();
  629.  IF    (argNum > 0)
  630.   THEN    ar.GetArg(1, strBuf, len);
  631.     hp.Allocate(TextAttr.name, len);
  632.     el.CopyMem(S.ADR(strBuf), TextAttr.name, len);
  633.     
  634.     IF    (argNum > 1)
  635.      THEN    ar.GetArg(2, strBuf, len);
  636.         cv.StrToVal(strBuf, long, signed, 10, err);
  637.         TextAttr.ySize:= INTEGER(long);
  638.      END; (* if *)
  639.   END; (* if *)
  640.  
  641.  END GetArguments;
  642.  
  643.  
  644.  
  645. (* MAIN ========================================================================= *)
  646.  
  647. VAR    idcmpMask,
  648.     signals        : S.LONGSET;
  649.     winSig        : SHORTCARD;
  650.     done        : BOOLEAN;
  651.  
  652. BEGIN
  653.  
  654. GetArguments;
  655. Init;
  656.  
  657. winSig:= Win^.userPort^.sigBit;
  658. idcmpMask:= S.LONGSET{winSig};
  659.  
  660. WHILE    NOT done
  661.  DO    signals:= el.Wait(idcmpMask);
  662.     IF    (winSig IN signals)
  663.      THEN    done:= HandleMsgs() # 0;
  664.      END; (* if *)
  665.  END; (* while *)
  666.  
  667.  
  668. CLOSE
  669.  
  670. CleanUp;
  671.  
  672. END Pages.
  673.